package annotation;

/**
 * 利用反射获取方法上的注解
 */

import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.util.ResourceBundle;

public class Anno2Test {

    public static void main(String[] args) throws Exception {

        //1获取类
        Class c = Class.forName(ResourceBundle.getBundle("classinfo2").getString("className3"));
        //2获取方法
        Method doSomeMethod = c.getDeclaredMethod("dosome");

        if (doSomeMethod.isAnnotationPresent(MyAnno2.class)){
            MyAnno2 myAnno2 = doSomeMethod.getAnnotation(MyAnno2.class);
            System.out.println(myAnno2.name()+"--"+myAnno2.pwd());

        }



    }

    @MyAnno2(name = "hqq",pwd = "123")
    public void dosome(){

    }
}
